<template>
  <div class="m-order">
    <ul>
      <li v-if="cur.length">
        <el-row
          v-for="(item, idx) of cur"
          :key="idx"
        >
          <el-col :span="6">
            <img :src="item.img" alt="">
          </el-col>
          <el-col :span="9">
            <h4>{{ item.name }}</h4>
            <p>数量：{{ item.count }}</p>
          </el-col>
          <el-col :span="4">
            ￥{{ item.total }}
          </el-col>
          <el-col :span="3">
            {{ item.statusText }}
          </el-col>
          <el-col :span="2">
            <el-button
              size="mini"
              type="danger"
              icon="el-icon-delete"
              circle
              @click="handleDelete(item.id)"
            />
          </el-col>
        </el-row>
      </li>
      <li v-else class="empty">
        没有订单
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  props: {
    cur: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  methods: {
    async handleDelete(id) {
      const { status, data: { code } } = await this.$axios.post('/order/delete', {
        id
      })
      if (status === 200 && code === 0) {
        this.$router.go(0)
      }
    }
  }
}
</script>
